console.log("=====================")
// function Circle(r) {
//     this.r = r;
// }
// Circle.PI = 3.14159;
// Circle.prototype.area = function() {
//     return Circle.PI * this.r * this.r;
// }
//
// var c = new Circle(1.0);
// console.log(c.area());

console.log("=====================")
// 声明一个变量，将一个函数当作值赋给变量
var Circle = function() {
    var obj = new Object();
    obj.PI = 3.14159;

    obj.area = function( r ) {
        return this.PI * r * r;
    }
    return obj;
}

var c = new Circle();
console.log( c.area( 1.0 ) );
console.log("=====================")

{
    var a=5;
    let b=10;
}
console.log(a); // 5
// console.log(b); // error b is not defined

console.log("=====================")
var a=[];
for(var i=0;i<10;i++){
    a[i]=function(){
        console.log(i);
    };
}
a[6](); // 10

var b=[];
for(let i=0;i<10;i++){
    b[i]=function(){
        console.log(i);
    };
}
b[6]();    //6
